home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-02 / prodpack.zip / DB4PPSRC.EXE / BUILTIN.DEF < prev    next >
Text File  |  1993-03-09  |  18KB  |  428 lines

  1. //---------------------------------------------------------------------------
  2. // BUILTIN.DEF  Template builtin function selectors
  3. // Borland International (c) 1987, 1988, 1989, 1990
  4. //
  5. // Added common UDF's to bottom of builtin.def
  6. //
  7. // --------------------------------------------------------------
  8. // Builtin Functions
  9. // --------------------------------------------------------------
  10. // This set of selectors designate builtin functions which should
  11. // appear in templates as <selector>([parm][,parm]...)
  12. // They must be included in every template.
  13. //
  14. // *** DO NOT CHANGE ANY OF THE NUMBERS BELOW ***
  15. //
  16. //---------------------------------------------------------------------------
  17. {
  18. enum db_version_no = "2.0";
  19.  
  20. selectors
  21. #lstoff
  22. //
  23. // Note: <filename> could also be <expC>
  24. //
  25. ALLTRIM    340, // Trim leading and trailing blanks
  26.                 // Syntax: ALLTRIM(<expC>)
  27. APPEND     324, // Append to an existing output file
  28.                 // Syntax: APPEND(<filename>)
  29. ASC        301, // Ascii value of first char of string
  30.                 // Syntax: ASC(<expC>)
  31. ASKUSER    344, // Prompt user for keyboard input
  32.                 // Syntax: ASKUSER(<expC>,<expC>,<expN>)
  33. AT         302, // Substring search
  34.                 // Syntax: AT(<expC>,<expC>)
  35. ATALPHA    303, // Locate first nonblank alpha numeric
  36.                 // Syntax: ATALPHA(<expC>)
  37. ATOMC      332, // Get sublist data from cursor
  38.                 // Syntax: ATOMC(<cursor>,<expN>)
  39. BACKSLASH  321, // Literal backslash
  40.                 // Syntax: BACKSLASH()
  41. BREAKPOINT 378, // Break during gen to allow user to change trace level
  42.                 // Works in stand alone dGEN.exe
  43.                 // Syntax: BREAKPOINT(<expC>)
  44. CGET       368, // Input string
  45.                 // Syntax: CGET()
  46. CHR        304, // Return one char string from ascii value
  47.                 // Syntax: CHR(<expN>)
  48. CLS        367, // Clear the screen
  49.                 // Syntax: CLS()
  50. COL1       352, // Left column of object frame
  51.                 // Syntax: COL1()
  52. COL2       353, // Right column of object frame
  53.                 // Syntax: COL2()
  54. COPY       325, // Copy text file to output stream
  55.                 // Syntax: COPY(<filename>)
  56. COUNTC     355, // Cursor's incremental count
  57.                 // Syntax: COUNTC(<cursor>)
  58. CPUT       366, // Put string to console at current location
  59.                 // Syntax: CPUT(<expC>)
  60. CREATE     323, // Create an output file
  61.                 // Syntax: CREATE(<filename>)
  62. CURLINE    338, // Current printed line
  63.                 // Syntax: CURLINE()
  64. CURSOR_POS 365, // Set cursor position on the screen (row,col)
  65.                 // Syntax: CURSOR_POS(<expN>,<expN>)
  66. DATE       333, // Get system date and time
  67.                 // Syntax: DATE()
  68. DEBUG      377, // Debug switch - takes values from 0 to 4
  69.                 // 0=Line number only to 4=full debug trace
  70.                 // Works in stand alone dGEN.exe
  71.                 // Syntax: DEBUG(<expN>)
  72. EOC        329, // Check for cursor off end of foreach loop
  73.                 // Syntax: EOC(<cursor>)
  74. EXEC       369, // Execute a DOS program
  75.                 // Syntax: EXEC(<filename>)
  76. FILEDATE   360, // Return file date as num
  77.                 // Syntax: FILEDATE(<filename>)
  78. FILEDRIVE  309, // Return drive:
  79.                 // Syntax: FILEDRIVE(<filename>)
  80. FILEERASE  379, // Erase a dos file
  81.                 // Syntax: FILEERASE(<filename>)
  82. FILEEXIST  343, // Test for file existence
  83.                 // Syntax: FILEEXIST(<filename>)
  84. FILEFIND   382, // Return full specification of the found file
  85.                 // Syntax: FILEFIND(<filename>,"<search flag list>")
  86.                 // A=unambiguous SYSTEM file name
  87.                 // 1=unambiguous NORMAL file name
  88.                 // 2=Current DOS drive/directory
  89.                 // 3=DOS path, 4=dBASE SET PATH, 5=dBASE home drive/directory
  90.                 // 6=DEFAULT drive/directory, 7=SQLHOME drive/directory
  91. FILENAME   307, // Return file root.extension
  92.                 // Syntax: FILENAME(<filename>)
  93. FILEOK     345, // Test for file name validity
  94.                 // Syntax: FILEOK(<filename>)
  95. FILEPATH   308, // Return file path
  96.                 // Syntax: FILEPATH(<filename>)
  97. FILEROOT   306, // Return file name root
  98.                 // Syntax: FILEROOT(<filename>)
  99. FILETYPE   305, // Return file extension
  100.                 // Syntax: FILETYPE(<filename>)
  101. FILESIZE   362, // Return file size as num
  102.                 // Syntax: FILESIZE(<filename>)
  103. GETENV     359, // Returns a environment variable from DOS
  104.                 // Syntax: GETENV(<expC>)
  105. IIDC       357, // Return internal selector number of item at cursor
  106.                 // Syntax: IIDC(<cursor>)
  107. LEN        310, // String length
  108.                 // Syntax: LEN(<expC> or <expN>)
  109. LMARG      336, // Left margin column
  110.                 // Syntax: LMARG(<expN>)
  111. LOWER      318, // Convert to lower case
  112.                 // Syntax: LOWER(<expC>)
  113. LTRIM      311, // Trim leading blanks
  114.                 // Syntax: LTRIM(<expC>)
  115. MAKEC      326, // Create a cursor
  116.                 // Syntax: MAKEC(<expN>[,<cursor>])
  117. MAX        313, // Return max of two numbers
  118.                 // Syntax: MAX(<expN>,<expN>)
  119. MIN        314, // Return min of two numbers
  120.                 // Syntax: MIN(<expN>,<expN>)
  121. NEWFRAME   348, // Change to a different object
  122.                 // application object
  123.                 // Syntax: NEWFRAME(<expC>)
  124. NEXTC      328, // Advance a cursor
  125.                 // Syntax: NEXTC(<cursor>)
  126. NMSG       381, // Output a message on the dbase navigation line 23
  127.                 // Syntax: NMSG(<expC>)
  128. NUMSET       363, // Get dbase number setting
  129.                 // Syntax: NUMSET(<expN>)
  130. PAGEJECT   347, // Inserts a chr(12) and resets curline() to 0
  131.                 // Syntax: PAGEJECT()
  132. PAGEL      337, // Printed lines per output page
  133.                 // Syntax: PAGEL(<expN>)
  134. PATHEXIST  370, // Test existence of a dos directory
  135.                 // Syntax: PATHEXIST(<expC>)
  136. PAUSE      334, // Output a breakpoint message and pause (line 24)
  137.                 // Syntax: PAUSE(<expC>)
  138. PMSG       380, // Output a message on the dbase message line 24
  139.                 // Syntax: PMSG(<expC>)
  140. POKE       349, // Unformatted print
  141.                 // Could use this to make dbase file headers, macro files
  142.                 // Syntax: POKE(<expC> [,<expC>,....])
  143. PRINT      322, // Print argument list
  144.                 // Syntax: PRINT(<expC>)
  145. REPLICATE  342, // Make a string of a given character
  146.                 // Syntax: REPLICATE(<expC>)
  147. ROW1       350, // Top row of object frame
  148.                 // Syntax: ROW1()
  149. ROW2       351, // Bottom row of object frame
  150.                 // Syntax: ROW2()
  151. RTRIM      312, // Trim trailing blanks
  152.                 // Syntax: RTRIM(<expC>)
  153. SCREEN     335, // Get a line of the screen
  154.                 // Syntax: SCREEN(<expN>)
  155. SETC       327, // Set new cursor location
  156.                 // Syntax: SETC(<cursor>,<expN>)
  157. SPACE      341, // Make a string of spaces
  158.                 // Syntax: SPACE(<expC>)
  159. STR        315, // Convert number to string
  160.                 // Syntax: STR(<expN>)
  161. STRSET     364, // Get dbase string setting
  162.                 // Syntax: STRSET(<expC>)
  163. SUBSTR     316, // Extract a substring
  164.                 // Syntax: SUBSTR(<expC>,<expN>,<expN>)
  165. TABTO      339, // Tab over to given column
  166.                 // Syntax: TABTO(<expN>)
  167. TEXTCLOSE  372, // Close text input stream
  168.                 // Syntax: TEXTCLOSE()
  169. TEXTGETC   373, // Get character from text input stream
  170.                 // Syntax: TEXTGETC()
  171. TEXTGETL   374, // Get line from text input stream
  172.                 // Syntax: TEXTGETL()
  173. TEXTGPOS   375, // Get file position from text input stream
  174.                 // Syntax: TEXTGPOS()
  175. TEXTOPEN   371, // Open text input stream
  176.                 // Syntax: TEXTOPEN(<filename>)
  177. TEXTSPOS   376, // Set file Position of text input stream
  178.                 // Syntax: TEXTSPOS(<expN>)
  179. TYPEC      356, // Return type of item at current cursor
  180.                 // Syntax: TYPEC(<cursor>)
  181. UPPER      317, // Convert to upper case
  182.                 // Syntax: UPPER(<expC>)
  183. VAL        319, // Convert string to number
  184.                 // Syntax: VAL(<expC>)
  185. VALC       358, // Return value of item at current cursor
  186.                 // Syntax: VALC(<cursor>)
  187. VERSION    320, // Return version number of apgen
  188.                 // Syntax: VERSION()
  189. NAMETOKEN  384, // Returns: a<0 validate, =0 count, >0 fetch
  190.                 // Syntax: NAMETOKEN(string,action) a<0 validate, =0 count, >0 fetch
  191. IMPORT     385, // Imports a dBASE object and outputs a BNL object
  192.                 // Syntax: IMPORT(infile,outfile,1|2|3|4)  1=qbe, 2=upd, 3=dbf, 4=cat
  193. TOKEN      386, // Returns the nth item of a delimited string
  194.                 // Syntax: TOKEN( expC:delimiter, expC:string, expN:itemno )
  195. ARGUMENT   387, // Returns the string passed in be the DGEN function or -P option
  196.                 // Syntax: ARGUMENT()
  197. //
  198. // End of Builtin functions
  199. //--------------------------------------------------------------
  200. //
  201. // Aggregate selectors  (e.g. foreach dosfile k in "*.doc" ... next k)
  202. //
  203. ATTRIBUTE  1002, // All attribute values in an element or frame
  204. DOSFILE     331, // Dos file list element
  205. #lston
  206. ;
  207. }
  208. {
  209. //--------------------------------------------------------------
  210. // Enum Statements for dBASE IV internal Settings
  211. // Use with functions numset() & strset()
  212. //
  213. // For convenience this enum declaration has been placed in this
  214. // file, since they can be used in all design objects
  215. //--------------------------------------------------------------
  216. // Enum for numset()
  217. // Note: FSE = Full Screen Edit
  218. //
  219. enum _device_file = 0,  //  0 File handle for SET DEVICE TO <filename>
  220.      _blocksize ,       //  1 Number of 512-byte pages in DBT     
  221.      _flgalter ,        //  2 Output routed to alt. file        
  222.      _flgbell  ,        //  3 Bell 0:off 1:on
  223.      _flgcarry ,        //  4 Carry 0:off 1:on
  224.      _flgcent  ,        //  5 Use 4-digit years            
  225.      _flgclock ,        //  6 Clock 0:off 1:on
  226.      _flgcnfrm ,        //  7 Confirm 0:off 1:on
  227.      _flgcolor ,        //  8 Color set flag 0=b/w 1=cga 2=ega24 4=mono43
  228.                         //                  6=ega43  3 & 5=N/A
  229.      _flgconsole,       //  9 Console 0:off 1:on
  230.      _flgcrypt ,        // 10 File encryption 0:off 1:on
  231.      _flgcursgn,        // 11 Currency symbol display 0:left 1:right
  232.      _flgdebug ,        // 12 Route STEP, ECHO to printer 0:off 1:on
  233.      _flgdelete,        // 13 Deleted records vanish 0:off 1:on
  234.      _flgdelim ,        // 14 Delimiters 0:off 1:on
  235.      _flgdesign,        // 15 Design mode 0:off 1:on
  236.      _flgdev ,            // 16 Always compile file 0:off 1:on
  237.      _flgdohist,        // 17 Do History 0:off 1:on
  238.      _flgecho  ,        // 18 Echo 0:off 1:on
  239.      _flgesc   ,        // 19 Escape 0:off 1:on
  240.      _flgexact ,        // 20 Exact 0:off 1:on
  241.      _flgexcl  ,        // 21 Exclusive 0:off 1:on
  242.      _flgfield ,        // 22 fields 0:off 1:on
  243.      _flgfixed ,        // 23 Fixed point 0:off 1:on
  244.      _flgflush ,        // 24 Autosave 0:off 1:on
  245.      _flghead  ,        // 25 Headings on DISPLAY, SUM, etc. 0:off 1:on
  246.      _flghelp  ,        // 26 Offer help on error 0:off 1:on
  247.      _flghist  ,        // 27 History 0:off 1:on
  248.      _flginstruct,      // 28 Instruct 0:off 1:on
  249.      _flginten ,        // 29 High intensity 0:off 1:on
  250.      _flgmenu  ,        // 30 Put menus up in FSE 0:off 1:on
  251.      _flgnear  ,        // 31 Stay at next record if SEEK/FIND fail 0:off 1:on
  252.      _flgprint ,        // 32 Route output to printer        
  253.      _flgscore ,        // 33 FALSE:  screen doesn't use line 0    
  254.      _flgscprt ,        // 34 0:@'s to screen 1:  @'s routed to printer        
  255.      _flgshare ,        // 35 Allow shared access to databases    
  256.      _flgspace ,        // 36 Set space ON/off (for print engine).
  257.      _flgsql,            // 37 0: dBASE mode 1: SQL mode      
  258.      _flgsqlcode,       // 38 1: executing SQL generated cmds
  259.      _flgstatus,        // 39 Status 0:off 1:on
  260.      _flgstep,          // 40 Single-step DO files 0:off 1:on
  261.      _flgtalk ,         // 41 Talk 0:off 1:on
  262.      _flgtitle,         // 42 Titles 0:off 1:on
  263.      _flgtrap,            // 43 Trap 0:off 1:on
  264.      _flguniq,          // 44 Indices 0:Non-unique 1: Unique keys
  265.      _flgautolk,        // 45 Automatic lock flag for network 0:off 1:on
  266.      _flgrefresh,       // 46 The refresh count Returns: Number
  267.      _memowidth,        // 47 Displayed width of memo fields Returns: Number
  268.      _mindec,           // 48 Minimum (or fixed) # decimals Returns: Number
  269.      _odometer,         // 49 Interval odometer is updated Returns: Number
  270.      _safety,           // 50 Safety 0:off 1:on
  271.      _setmrgn,          // 51 Printer left margin Returns: Number
  272.      _reprocess,        // 52 Reprocess count Returns: Number
  273.      _nbuffers,         // 53 Maximum number of I/O buffers Returns: Number
  274.      _lenYNOF           // 54 Default max of YES/NO/ON/OFF
  275. ;
  276. //
  277. // Enum for strset()
  278. // Note: FSE = Full Screen Edit
  279. //
  280. enum _getdelim = 0,     //  0 FSE l,r delimiters        
  281.      _disp_currency,    //  1 Current FSE currency string
  282.      _def_currency,     //  2 Default FSE currency string
  283.      _lang_type,        //  3 Language type designator string
  284.      _wordproc,            //  4 Program used for memo fields
  285.      _tedit,            //  5 Program used for MODIFY COMMAND
  286.      _dotprompt,        //  6 Dot prompt string
  287.      _sqlprompt,        //  7 Sql prompt string
  288.      _sql_dir,            //  8 Path for SQL system files
  289.      _sql_database,     //  9 Name of SQL system database
  290.      _font_file,        // 10 Name of font file
  291.      _defdrive,            // 11 DBASE default drive
  292.      _disp_period,      // 12 Current display decimal point
  293.      _disp_comma,       // 13 Current FSE separator
  294.      _def_period,       // 14 Default display decimal point
  295.      _def_comma         // 15 Default FSE separator
  296. ;
  297. //
  298. // Enum for Monitor types
  299. // Values returned by numset(_flgcolor)
  300.  enum mono   = 0,
  301.       cga,
  302.       ega25,
  303.       mono43,
  304.       ega43,
  305.       vga25,
  306.       vga43,
  307.       vga50
  308. ;
  309. //
  310. // Values returned by Object Class
  311. //
  312.  enum app    = 1,  // 1) Application object
  313.       popup,       // 2) Popup object
  314.       f_pick,      // 3) File picklist object
  315.       s_pick,      // 4) Fields picklist object
  316.       v_pick,      // 5) Values picklist object
  317.       bar = 7,     // 7) Horizontal Bar object
  318.                    // 6,8 N/A
  319.       btch   = 9   // 9) Batch object
  320.       form     = 11,
  321.       label    = 12,
  322.       report   = 13,
  323.       table_dbf= 20,
  324.       update   = 21,
  325.       query    = 22,
  326.       catalog  = 23
  327. ;
  328. //
  329. // Values returned Textgetl() or Textgetc() at End of file
  330. //
  331. enum eof = -1;
  332. //
  333. // Enum string constants for international translation
  334. //
  335. enum any_key      = "Press any key ...",
  336.      read_only    = " can't be opened - possible read only file.  ",
  337.      pick_debug     = "Pick the debug level you want",
  338.      gen_request  = "Generation request cancelled.  ",
  339.      gen_complete = "Generation is complete.  "
  340. ;
  341. //
  342. // Generic User Defined functions follow
  343.  
  344. define trim(mstring)
  345.  // Takes a string and returns a right trimmed string
  346.  // dBASE language calls it trim or rtrim
  347.  return rtrim(mstring);
  348. enddef
  349.  
  350. define say_center(mrow, mstring)
  351.    // mrow = Row to put string
  352.    // mstring = Text to display to Row position
  353.    enum width_of_screen = 80;
  354.    var mcol;
  355.    mcol = ( width_of_screen / 2) - ( len( mstring)/2)
  356.    cursor_pos( mrow, mcol )
  357.    cput(mstring)
  358. enddef
  359.  
  360. define say(mrow, mcol, mstring)
  361.    // mrow = Row to put string
  362.    // mcol = Column to put string
  363.    // mstring = Text to display to Row position
  364.    cursor_pos( mrow, mcol )
  365.    cput( mstring )
  366. enddef
  367.  
  368. define abs(value)
  369.    // Absolute value of a number
  370.    // value = Number to convert to absolute value
  371.    if value < 0 then
  372.      value = val( substr( str( value ), 2))
  373.    endif
  374.    return value;
  375. enddef
  376.  
  377. define beep(value)
  378.    // Simulate a bell
  379.    // value = Number of times to beep
  380.    var cnt;
  381.    cnt = 1
  382.    do while cnt <= value
  383.       cput( chr(7) )
  384.       cnt = cnt + 1
  385.    enddo
  386.    return;
  387. enddef
  388.  
  389. define cap_first(string)
  390.    // Takes and returns a string with first letter capped
  391.    return upper( substr( string,1,1)) + lower( substr( string,2))
  392. enddef
  393.  
  394. define nul2zero(numbr)
  395.    // if number is nul and we are expecting a zero - convert the nul to 0
  396.    return (numbr ? numbr : 0);
  397. enddef
  398.  
  399. define get_dbtmp()
  400.    // Get the DOS environment variable dbtmp or tmp
  401.    var dbtmp;
  402.    dbtmp = alltrim( getenv("dbtmp") ? getenv("dbtmp") : getenv("tmp") );
  403.    if dbtmp and substr( dbtmp, len(dbtmp), 1) != "\\" then
  404.       dbtmp = dbtmp + "\\"
  405.    endif
  406.    return dbtmp
  407. enddef
  408.  
  409. define pad_num(number)
  410.    // Pad a number with a leading "0" if less than 10
  411.    var str_number;
  412.  
  413.    str_number = alltrim(str( number ))
  414.    return ( len(str_number) == 1 ? "0"+str_number : str_number );
  415. enddef
  416.  
  417. define textgets(length)
  418.    // Get a string given the current starting location and a length of
  419.    // the string to return
  420.    var location, result;
  421.    location = textgpos()
  422.    result = substr( textgetl(), 1, length)
  423.    textspos( location + length)
  424.    return result;
  425. enddef
  426.  
  427. }
  428.